<?php Yii::app()->clientScript->registerScript('buttons',"

    $('#create').click(function(e){
      var checked = $('#menu-grid:checked')
    });

     $('.well button').click(function(e){

          var id,checked,i,checkedLen,checkedId = [];
          id = $(this).attr('id');
          checked = $('#menu-grid :checked');

          if(checked.length >= 1 && id != 'create')
          {
              checkedLen = checked.length;
              for(i=0;i<checkedLen;i++)
              {
                 checkedId[i] = $(checked[i]).val();
              }
              if(id == 'del')
              {
                    $.ajax({
                    url:'ajaxitemdelete',
                    data:{items:checkedId},
                    dataType:'JSON',
                    success:function(resp){
                         $.fn.yiiGridView.update('menu-grid');
                    }
                });
              }
              else if(id == 'pub')
              {
                    $.ajax({
                    url:'ajaxitempublish',
                    data:{items:checkedId},
                    dataType:'JSON',
                    success:function(resp){
                         $.fn.yiiGridView.update('menu-grid');
                         }
                    });
              }
              else if(id == 'unpub')
              {
                    $.ajax({
                    url:'ajaxitemunpublish',
                    data:{items:checkedId},
                    dataType:'JSON',
                    success:function(resp){
                         $.fn.yiiGridView.update('menu-grid');
                         }
                    });
              }

              else if(id === 'edit')
              {
                    document.location.replace('update/id/'+checkedId[0]);
              }

          }
          else if(id === 'create')
              {
                    document.location.replace('create');
              }
          else
          {
           alert( $('#alert p').text());
          }
        });



")?>
<div class="well">

    <?php echo CHtml::htmlButton(CHtml::tag('i',array('class'=>'fa fa-plus white'),'').'&nbsp'.Yii::t('MenuModule.base','Create'),array('id'=>'create','class'=>'btn btn-success'))?>
    <?php echo CHtml::htmlButton(CHtml::tag('i',array('class'=>'fa fa-edit blue'),'').'&nbsp'.Yii::t('MenuModule.base','Edit'),array('id'=>'edit','class'=>'btn btn-default'))?>
    <?php echo CHtml::htmlButton(CHtml::tag('i',array('class'=>'fa fa-check green'),'').'&nbsp'.Yii::t('MenuModule.base','Publish'),array('id'=>'pub','class'=>'btn btn-default'))?>
    <?php echo CHtml::htmlButton(CHtml::tag('i',array('class'=>'fa fa-minus-circle red'),'').'&nbsp'.Yii::t('MenuModule.base','Take off from publication'),array('id'=>'unpub','class'=>'btn btn-default'))?>
    <?php echo CHtml::htmlButton(CHtml::tag('i',array('class'=>'fa fa-times-circle-o red'),'').'&nbsp'.Yii::t('MenuModule.base','Delete'),array('id'=>'del','class'=>'btn btn-default'))?>

</div>
<div id="alert" style="display: none"><p><?php echo Yii::t('MenuModule.base','Please select an item from the list.')?></p></div>

